function [rhoCross,sigma2,RvHatPooled] = BootstrapARone_CrossSection(residualsTrans)

[T,ny] = size(residualsTrans);
X      = ones(T*(ny-1),2);
Y      = zeros(T*(ny-1),1);
idx    = 0;
for t=1:T
   select  = ~isnan(residualsTrans(t,:)); 
   resUsed = residualsTrans(t,select)';
   nyUsed  = sum(select);
   X(1+idx:idx+nyUsed-1,2) = resUsed(1:nyUsed-1,1);  
   Y(1+idx:idx+nyUsed-1,1) = resUsed(2:nyUsed,1); 
   idx     = idx + nyUsed-1;
end
% The regression 
XX          = X'*X;
betta       = XX\(X'*Y);
epsFit      = Y - X*betta;
sigma2      = epsFit'*epsFit/idx;
RvHatPooled = XX(2,2)/idx; 
rhoCross    = betta(2,1);
